package com.hwadee.backend.controller;

import com.hwadee.backend.entity.HealthRecord.HealthRecord;
import com.hwadee.backend.entity.log.Loggy;
import com.hwadee.backend.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/log")
public class LogController {
    @Autowired
    private LogService logService;

    @GetMapping("")
    public List<Loggy> log() {
        return logService.getLogs();
    }

    @GetMapping("/getHealthRecord/{recordId}")
    public HealthRecord getHealthRecord(@PathVariable int recordId) {
        return logService.getHealthRecord(recordId);
    }

    @PostMapping("/add")
    public void addLog(@RequestBody Loggy loggy) {
        logService.addLog(loggy);
    }

    @DeleteMapping("/delete/{logId}")
    public void deleteLog(@PathVariable int logId) {
        logService.deleteLog(logId);
    }
}
